using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

namespace ZombieHigh2.Audio
{
    public class AudioSystem
    {
        AudioEngine _audioEngine;
        WaveBank _waveBank;
        SoundBank _soundBank;

        public AudioSystem()
        {
        }

        public void Initialize()
        {
            _audioEngine = new AudioEngine(@"Data\Audio\zombies.xgs");
            _waveBank = new WaveBank(_audioEngine, @"Data\Audio\Wave Bank.xwb");
            _soundBank = new SoundBank(_audioEngine, @"Data\Audio\Sound Bank.xsb");
        }

        public void PlayCue(String cueName)
        {
            _soundBank.PlayCue(cueName);
        }

        public Cue GetCue(String name)
        {
            return _soundBank.GetCue(name);
        }

        public void Update()
        {
            _audioEngine.Update();
        }

        public void StopCue(Cue cue)
        {
            cue.Stop(AudioStopOptions.Immediate);
        }

        public void Stop(String name)
        {
            Cue cue = _soundBank.GetCue(name);
            if (cue.IsPlaying)
                cue.Stop(AudioStopOptions.Immediate);
        }

    }
}
